package com.cyou.qb.front.web;

import java.util.ArrayList;
import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import com.cyou.qb.common.domain.FrontAward;
import com.cyou.qb.common.service.AwardService;

@Controller
@RequestMapping(value="/award")
public class AwardController extends BaseController{

	@Resource(name="AwardServiceCacheImpl")
	private AwardService awardService;
	@RequestMapping(value="/index")
	
	public String index(Model model,HttpServletRequest request, HttpServletResponse response) throws Exception{
		System.out.println("I can be here");
		List<FrontAward> list = awardService.findAwardList();
		List<FrontAward> list1 = new ArrayList<FrontAward>();
		List<FrontAward> list2 = new ArrayList<FrontAward>();
		List<FrontAward> list3 = new ArrayList<FrontAward>();
		List<FrontAward> list4 = new ArrayList<FrontAward>();
		for (FrontAward frontAward : list) {
			if(frontAward.getChannel().equals("1")){
				list1.add(frontAward);
			}else if(frontAward.getChannel().equals("2")){
				list2.add(frontAward);
			}else if(frontAward.getChannel().equals("3")){
				list3.add(frontAward);
			}else{
				list4.add(frontAward);
			}
		}
		model.addAttribute("page1",list1);
		model.addAttribute("page2",list2);
		model.addAttribute("page3",list3);
		model.addAttribute("page4",list4);

		return "/activity/award";
	}
}
